package org.spbsu.apco.server.scheduler;

import org.spbsu.apco.common.task.core.Ticket;
import org.spbsu.apco.server.taskset.BaseTaskSet;

import java.util.Collection;

/**
 * User: solozobov
 * Date: 17.11.12
 */
public interface Scheduler {

    /**
     * Schedules new task set for execution
     */
    void holdTaskSet(BaseTaskSet taskSet);

    /**
     * Returns new ticket for defined client
     */
    Ticket getNextTicketFor(String clientId);

    /**
     * Accepts result of finished task
     * @param clientId client where task was executed
     * @param taskId ID of finished task
     * @param result task execution result
     */
    void taskFinished(String clientId, long taskId, Object result);

    /**
     * Returns whether task set is finished
     */
    boolean isTaskSetFinished(BaseTaskSet baseTaskSet);

    /**
     * Returns results of task set
     * Results are collection of results of tasks which is not arguments for other tasks in the task set
     */
    Collection<Object> getTaskSetResults(BaseTaskSet baseTaskSet);
}
